import { addCsvData } from "../csv";
import { touchEventData } from "./event";

export enum MusicAction {
    Click = 'Click', // 点击事件
    Input = 'Input', // 输入事件
    Swipe = 'Swipe', // 滑动事件
    Auto = 'Auto' // 自动事件 (通过特殊指令，自动触发的一系列事件)
}

// 音乐Widget
export enum MusicWidget {
    PlayMusic = 'PlayMusic', // 播放音乐
    PauseMusic = 'PauseMusic', // 暂停音乐
    NextMusic = 'NextMusic', // 下一首音乐
    PrevMusic = 'PrevMusic', // 上一首音乐
    MusicProgress = 'MusicProgress', // 音乐进度条
    SearchInputIcon = 'SearchInputIcon', // 搜索ICON
    SearchInput = 'SearchInput', // 搜索输入框
    SearchSuggestion = 'SearchSuggestion', // 搜索推荐项
    MusicStore = 'MusicStore', // 音乐商店
    MusicStoreList = 'MusicStoreList', // 音乐列表项
    MusicStoreItem = 'MusicStoreItem', // 音乐列表项
    MusicStoreTabItem = 'MusicStoreTabItem', // 音乐商店标签列表项
    MusicStoreRandomPlayList = 'MusicStoreRandomPlayList', // 音乐商店随机列表
    MusicStoreRandomPlayItem = 'MusicStoreRandomPlayItem', // 音乐商店随机播放
}

// 音乐事件
function eventMusic(action: MusicAction.Click, widget: MusicWidget.PlayMusic, eventKey: MusicWidget.PlayMusic, widgetId: MusicWidget.PlayMusic, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.PauseMusic, eventKey: MusicWidget.PauseMusic, widgetId: MusicWidget.PauseMusic): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.NextMusic, eventKey: MusicWidget.NextMusic, widgetId: MusicWidget.NextMusic, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.PrevMusic, eventKey: MusicWidget.PrevMusic, widgetId: MusicWidget.PrevMusic, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.SearchInputIcon, eventKey: MusicWidget.SearchInputIcon, widgetId: MusicWidget.SearchInputIcon): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.SearchInput, eventKey: `${MusicWidget.SearchInput}_focus`, widgetId: MusicWidget.SearchInput): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.SearchSuggestion, eventKey: `${MusicWidget.SearchSuggestion}${number}`, widgetId: `${MusicWidget.SearchSuggestion}${number}`, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.MusicStoreItem, eventKey: MusicWidget.MusicStoreItem, widgetId: MusicWidget.MusicStoreItem, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.MusicStoreTabItem, eventKey: MusicWidget.MusicStoreTabItem, widgetId: MusicWidget.MusicStoreTabItem, value: string): void;
function eventMusic(action: MusicAction.Click, widget: MusicWidget.MusicStoreRandomPlayItem, eventKey: MusicWidget.MusicStoreRandomPlayItem, widgetId: MusicWidget.MusicStoreRandomPlayItem, value: string): void;

function eventMusic(action: MusicAction.Input, widget: MusicWidget.SearchInput, eventKey: `${MusicWidget.SearchInput}_input`, widgetId: MusicWidget.SearchInput, value: string): void;

function eventMusic(action: MusicAction.Swipe, widget: MusicWidget.MusicStore, eventKey: MusicWidget.MusicStore, widgetId: MusicWidget.MusicStore, value: touchEventData): void;
function eventMusic(action: MusicAction.Swipe, widget: MusicWidget.MusicStoreList, eventKey: MusicWidget.MusicStoreList, widgetId: MusicWidget.MusicStoreList, value: touchEventData): void;
function eventMusic(action: MusicAction.Swipe, widget: MusicWidget.MusicStoreRandomPlayList, eventKey: MusicWidget.MusicStoreRandomPlayList, widgetId: MusicWidget.MusicStoreRandomPlayList, value: touchEventData): void;
function eventMusic(action: MusicAction.Swipe, widget: MusicWidget.MusicProgress, eventKey: `${MusicWidget.MusicProgress}_swipe`, widgetId: MusicWidget.MusicProgress, value: touchEventData): void;

function eventMusic(action: MusicAction.Auto, widget: null, eventKey: `${MusicWidget.PlayMusic}_auto`, widgetId: null, value: string): void;
function eventMusic(action: MusicAction.Auto, widget: null, eventKey: `${MusicWidget.PauseMusic}_auto`, widgetId: null): void;
function eventMusic(action: MusicAction.Auto, widget: null, eventKey: `${MusicWidget.NextMusic}_auto`, widgetId: null, value: string): void;
function eventMusic(action: MusicAction.Auto, widget: null, eventKey: `${MusicWidget.PrevMusic}_auto`, widgetId: null, value: string): void;

function eventMusic(action: MusicAction, widget: MusicWidget | null, eventKey: any, widgetId: any, value?: any): void {
    const data = { app: "Music", event_key: eventKey, data_json: { action, widget_type: widget, widget_id: widgetId, value } };
    addCsvData(data);
}
export { eventMusic }